package cn.cdutetc.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "HelloServlet", value = "/hello")
public class HelloServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setAttribute("hellorequest","hello,hello");
        System.out.println(request.getSession().getAttribute("session1"));
        System.out.println(request.getSession().getAttribute("session2"));
        response.sendRedirect("/world");//转发和重定向后的代码都会被执行
       // request.getRequestDispatcher("/world").forward(request,response);
        System.out.println("end............");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
